//
//  FlutterPlugin_aNativeCallFlutter.m
//  flutter_plugin_a
//
//  Created by hello on 2020/1/9.
//

#import "FlutterPlugin_aNativeCallFlutter.h"

@interface FlutterPlugin_aNativeCallFlutter()
@property (nonatomic, strong) FlutterMethodChannel *channel;
@end

@implementation FlutterPlugin_aNativeCallFlutter

+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
    FlutterMethodChannel* channel = [FlutterMethodChannel
                                     methodChannelWithName:@"flutter_plugin_a:native_call_flutter"
                                     binaryMessenger:[registrar messenger]];
    FlutterPlugin_aNativeCallFlutter* instance = [[FlutterPlugin_aNativeCallFlutter alloc] init];
    instance.channel = channel;
    [registrar addMethodCallDelegate:instance channel:channel];
    
    [instance performSelector:@selector(test) withObject:nil afterDelay:1.0f];
}

- (void)test {
    [self log_Integer];
    [self log_String];
    [self log_Array];
    [self log_Dic];
}

- (void)log_Integer {
    [self.channel invokeMethod:@"getInt" arguments:nil result:^(id  _Nullable result) {
        NSLog(@"======== log_Integer ========");
        NSLog(@"%@", result);
    }];
}

- (void)log_String {
    [self.channel invokeMethod:@"getString" arguments:nil result:^(id  _Nullable result) {
        NSLog(@"======== log_String ========");
        NSLog(@"%@", result);
    }];
}

- (void)log_Array {
    [self.channel invokeMethod:@"getList" arguments:nil result:^(id  _Nullable result) {
        NSLog(@"======== log_Array ========");
        NSLog(@"%@", result);
    }];
    
}

- (void)log_Dic {
    [self.channel invokeMethod:@"getMap" arguments:nil result:^(id  _Nullable result) {
        NSLog(@"======== log_Dic ========");
        NSLog(@"%@", result);
    }];
    
}

@end

